package com.hzdl.library.util;

import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;

public class DateUtil {

    static SimpleDateFormat sdf = null;

    static{
        sdf = new SimpleDateFormat("yyyy-MM-dd");
    }

    //把时间转字符串
    public static String dateString(Date d){
        //时间转换类
        String format = sdf.format(d);
        return format;
    }

    //把字符串转时间   2020-10-14 12:12:12
    public static Date stringDate(String str){
        Date parse =null;
        try {
            parse = sdf.parse(str);
        } catch (ParseException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }
        return parse;
    }

}
